#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
class hjx
{
public:
    string xiangjia(const string& s1, const string& s2)
    {
        string stret;
        int end1 = s1.size() - 1;
        int end2 = s2.size() - 1;
        int next = 0;
        while (end1 >= 0 || end2 >= 0)
        {
            int e1 =0;
            int e2 =0;
            if (end1 >= 0)
            {
                e1 = s1[end1] -'0';
            }
            if (end2 >= 0)
            {
                e2 = s2[end2] - '0';
            }
            int ret = e1 + e2 + next;
            if (ret > 9)
            {
                ret -= 10;
                next = 1;
            }
            else
            {
                next = 0;
            }
            stret += (ret + '0');//逆序了要转回过来
//            stret.insert(stret.begin(),ret+'0');
            ret = 0;//重置
            end1--;
            end2--;
        }
        if(next==1)//"1"+"9"这种特殊情况会用到
        {
              stret+='1';
//            stret.insert(stret.begin(),'1');
        }
        reverse(stret.begin(),stret.end());//reverse是逆置函数它的头文件是algorithm
        return stret;
    }
    string xiangcheng(const string &s1,const string &s2)
    {
        string i("0");
        string one("1");//用于i累加
        string ret="0";
        while(i!=s1)
        {
            i=xiangjia(i,one);
            ret=xiangjia(ret,s2);
        }
        return ret;
    }
};
int main()
{
    string s1("20");
    string s2("3");
    hjx h1;
    cout<<h1.xiangcheng(s1,s2);

    return 0;
}
































